<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
        .ball {
            border: 1px solid black;
            height: 20px;
            width: 20px;
            border-radius: 50%;
        }
    </style>

</head>
<!-- 
bug1:样式里面的transform写成了transfrom
-->

<body>
    <div id="a">
        <input type="button" value="抛" @click='ametheds'>
        <transition v-on:before-enter="beforeEnter" v-on:enter="enter" v-on:after-enter="afterEnter">
            <div v-if='ifappear' class="ball"> </div>
        </transition>


    </div>

    <script>
        var a = new Vue({
            el: '#a ',
            data: {
                ifappear: false,
            },
            methods: {
                ametheds: function(el) {
                    this.ifappear = !this.ifappear;
                },
                beforeEnter: function(el) {
                    el.style.transform = 'translate(0,0)';

                },
                enter: function(el, done) {
                    el.offsetTop; //这个必须要才能使transition奏效
                    el.style.transform = 'translate(150px,250px)';
                    el.style.transition = 'all 1s ease';
                    done();
                    //done（）其实是afterEnter函数的引用，可以达到立即执行的效果
                },
                afterEnter: function(el) {
                    this.ifappear = !this.ifappear;

                },

            }


        })
    </script>
</body>

</html>